package com.example.myproject.controller;

import com.example.myproject.dto.AnalyseResponse;
import com.example.myproject.security.JwtAuthenticationFilter;
import com.example.myproject.service.AnalyseService;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/analyse")
public class AnalyseController {

    private final AnalyseService analyseService;

    public AnalyseController(AnalyseService analyseService) {
        this.analyseService = analyseService;
    }

    @GetMapping("/summary")
    public AnalyseResponse getAnalyse(@AuthenticationPrincipal JwtAuthenticationFilter.UserPrincipal principal) {
        Long userId = principal.getId();
        return analyseService.getAnalyse(userId);
    }
}
